// components/musiclist/musiclist.js
const app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    musiclist: Array,
  },

  /**
   * 组件的初始数据
   */
  data: {
    musicId: -1
  },
  /**
   * 页面生命周期
   */
  pageLifetimes: {
    show() {
      const playingMusicId = app.getPlayMusicId();
      this.setData({
        musicId: playingMusicId
      })
    }
  },
  /**
   * 组件的方法列表
   */
  methods: {
    selectSong(event) {
      console.log(event)
      const dataset = event.currentTarget.dataset;
      this.setData({
        musicId: parseInt(dataset.musicid)
      })
      wx.navigateTo({
        url: `../../pages/player/player?musicId=${dataset.musicid}&index=${dataset.index}`,
      })
    }
  }
})